import * as actionType from './constants'
import { Map } from 'immutable'

const defaultState = Map({
  topBanners: [], // 轮播图
  hotRecommends: [], // 热门推荐
  newAlbums: [], // 电台

  upRanking: {}, // 排行榜
  newRanking: {},
  originRanking: {}
})

function reducer(state = defaultState, action) {
  switch (action.type) {
    // 轮播图
    case actionType.CHANGE_TOP_BANNERS:
      return state.set('topBanners', action.topBanners)
    // 热门推荐
    case actionType.CHANGE_HOT_RECOMMEND:
      return state.set('hotRecommends', action.hotRecommends)
    // 专辑
    case actionType.CHANGE_NEW_ALBUM:
      return state.set('newAlbums', action.newAlbums)
    // 排行榜
    case actionType.CHANGE_UP_RANKING:
      return state.set('upRanking', action.upRanking)
    case actionType.CHANGE_NEW_RANKING:
      return state.set('newRanking', action.newRanking)
    case actionType.CHANGE_ORIGIN_RANKING:
      return state.set('originRanking', action.originRanking)
    default:
      return state
  }
}

export default reducer
